package com.linrui.basic.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.internet.MimeMessage;
@Component
public class MailCommonService{
    @Autowired
    private JavaMailSender javaMailSender;
public void calling() throws Exception{
        //创建复杂邮件对象
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();
        //发送复杂邮件的工具类
        MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true,"utf-8");
        helper.setFrom("274855230@qq.com");
        helper.setSubject("激活成功");
        http://img30.360buyimg.com/popWaterMark/jfs/t1/67988/7/14094/232759/5db64acfE6ab2b09e/38b5cb3dc38b4b1f.jpg"
        helper.setText("<h1>蓉车宝激活通知</h1>"+
        "<a href='http:locahost:8080'/>",true);
        //添加附件
//        helper.addAttachment("罗宾.jpg",new File("C:\\Users\\hm\\Desktop\\work\\aa.jpg"));
//        helper.addAttachment("压缩文件", new File("C:\\Users\\hm\\Desktop\\20191010\\2020-02-05-智能商贸-DAY4\\resources\\resources.zip"));
        //收件人
        helper.setTo("274855230@qq.com");

        javaMailSender.send(mimeMessage);
        }
}